{phan tich day n phan tu thang day con k phan tu giam dan}
program daycongiam;
uses crt;
const
	fi='daycongiam.inp';
    fo='daycongiam.out';
var
	f,g:text;
    n,k:integer;
    b,a:array[0..1001] of integer;
procedure nhap;
var	i:integer;
	begin
    	assign(f,fi);
        reset(f);
        	readln(f,n,k);
            for i:=1 to n do
            	read(f,a[i]);
        close(f);
    end;

procedure xuat;
var	i:integer;
	begin
    	writeln;
    	for i:=1 to k do
        	write(b[i]:5);
    end;
procedure dequy(d,x:integer);
var	i:integer;
	begin
    	if d=k then
        	begin
	        	xuat;
                dec(d);
                exit;
            end;
        for i:=x+1 to n do
        	begin
            	if a[i]<a[x] then
                	begin
	                	b[d]:=a[x];
                        dequy(d+1,i);
                    end;
            end;
    end;

procedure xuly;
var	d,i,j:integer;
	begin
    	dequy(1,0);
    	{for i:=1 to n-k+1 do
        	begin
            	d:=1;
                b[d]:=a[j];
                for j:=i+1 to n do
                	if a[j]<b[d] then
                    	begin
                        	inc(d);
                            b[d]:=a[j];
                            if d=k then
                            	begin
                            		xuat;
                                    if j<n then
                                    	
                                end;
                        end;
            end;}	
    end;
begin
clrscr;
	nhap;
    xuly;
end.